package com.huangpuweb.task.service.imp;

import com.huangpuweb.task.model.HpScenicNumber;
import com.huangpuweb.task.model.HpScenicRealTime;
import com.huangpuweb.task.service.SyncScenicSpotService;
import com.huangpuweb.task.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.xml.ws.Holder;
import java.util.List;

/**
 * @author rufeng
 * @date 2021/1/29 13:33
 */
@Service
public class SyncScenicSpotServiceImpl extends BaseScenicSpotServiceImp implements SyncScenicSpotService {
    @Override
    public void updateScenicSpot(HpScenicNumber hp) {
        String sql="update hp_scenic_number set name=?,isadmin=?,spotcode=?,spotname=?,maxtotal=?,maxrealtime=?,maxblue=?,maxyellow=?,maxred=?,realmaxblue=?,realmaxyellow=?,realmaxred=?,maxHeat=?,createTime=? where uuid=? ";
        update(sql,new Object[]{hp.getName(),hp.getIsadmin(),hp.getSpotcode(),hp.getSpotname(),hp.getMaxtotal(),hp.getMaxrealtime(), hp.getMaxblue(),hp.getMaxyellow(),hp.getMaxred(),hp.getRealmaxblue(),hp.getRealmaxyellow(),hp.getRealmaxred(),hp.getMaxHeat(), DateUtil.getDateTime(),hp.getUuid()});
    }

    @Override
    public String findScenicSpot(String uuid) {
        String sql="select uuid from hp_scenic_number where uuid=? ";
        return queryString(sql,new Object[]{uuid});
    }

    @Override
    public void insertScenicSpotByYuYuan(HpScenicRealTime hp) {
        String sql = "insert into hp_spot_realtime(spotid,updatetimer,totalnumber,realtimenumber,time,hour,increase,createTime) values(?,?,?,?,?,?,?,?)";
        update(sql,new Object[]{hp.getSpotid(),hp.getUpdatetimer(),hp.getTotalnumber(),hp.getRealtimenumber(),hp.getTime(),hp.getHour(),hp.getIncrease(),hp.getCreateTime()});
    }

    @Override
    public String findCurrentquery(String spotCode) {
        String sql = "select uuid from hp_scenic_number where spotcode=? ";
        return queryString(sql, new Object[]{spotCode});
    }

    @Override
    public void insertScenicSpot(HpScenicNumber hp) {
        String sql = "insert into hp_scenic_number(uuid,name,isadmin,spotcode,spotname,maxtotal,maxrealtime,maxblue,maxyellow,maxred,realmaxblue,realmaxyellow,realmaxred,maxHeat,createTime) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        update(sql, new Object[]{hp.getUuid(), hp.getName(), hp.getIsadmin(), hp.getSpotcode(), hp.getSpotname(), hp.getMaxtotal(), hp.getMaxrealtime(),
                hp.getMaxblue(), hp.getMaxyellow(), hp.getMaxred(), hp.getRealmaxblue(), hp.getRealmaxyellow(), hp.getRealmaxred(), hp.getMaxHeat(), hp.getCreateTime()});
    }
}
